package com.tencreat.domain.mall;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tencreat.common.core.domain.BaseEntity;
import com.tencreat.common.enums.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;


/**
 * 店铺订单对象 mall_store_order
 *
 * @author tencreat
 * @date 2021-08-19
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
@TableName("mall_store_order")
@ExcelIgnoreUnannotated
public class MallStoreOrder extends BaseEntity<MallStoreOrder> {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "ID")
    private Long id;

    /**
     * 用户表的用户ID
     */
    @ExcelProperty(value = "用户ID",order = 2)
    @ColumnWidth(9)
    @ApiModelProperty(value = "用户表的用户UUID")
    @TableField("`uuid`")
    private Long uuid;

    @ApiModelProperty(value = "优惠券ID")
    @TableField("`coupon_id`")
    private Long couponId;

    /**
     * 订单编号
     */
    @ExcelProperty(value = "订单编号",order = 1)
    @ApiModelProperty(value = "订单编号")
    @TableField("`order_sn`")
    private String orderSn;

    /**
     * 订单类型
     **/
    @ApiModelProperty(value = "订单类型")
    @TableField("`order_type`")
    private OrderType orderType;

    @ExcelProperty(value = "商品类型",order = 9)
    @ApiModelProperty(value = "订单类型")
    @TableField(exist = false)
    private String orderTypeDesc;

    @ApiModelProperty(value = "用户状态")
    @TableField("`status_user`")
    private UserOrderStatus statusUser;

    @ApiModelProperty(value = "商家状态")
    @TableField("`status_shop`")
    private ShopOrderStatus statusShop;

    /**
     * 订单状态
     */
    @ApiModelProperty(value = "订单状态")
    @TableField("`order_status`")
    private OrderStatus orderStatus;

    @ExcelProperty(value = "订单状态",order = 18)
    @ApiModelProperty(value = "订单状态")
    @TableField(exist = false)
    private String orderStatusDesc;


    /**
     * 售后状态，0是可申请，1是用户已申请，2是管理员审核通过，3是管理员退款成功，4是管理员审核拒绝，5是用户已取消
     */
//    @ExcelProperty(value = "售后状态，0是可申请，1是用户已申请，2是管理员审核通过，3是管理员退款成功，4是管理员审核拒绝，5是用户已取消")
    @ApiModelProperty(value = "售后状态，0是可申请，1是用户已申请，2 退款成功，3 是用户已取消")
    @TableField("`aftersale_status`")
    private Integer aftersaleStatus;

    @ApiModelProperty(value = "售后状态，0是可申请，1是用户已申请，2 退款成功，3 是用户已取消")
    @TableField(exist = false)
    @ExcelProperty(value = "售后状态",order = 19)
    private String aftersaleStatusDesc;

    /**
     * 收货人名称
     */
//    @ExcelProperty(value = "收货人名称")
    @ApiModelProperty(value = "收货人名称")
    @TableField("`consignee`")
    private String consignee;


    /**
     * 收货人手机号
     */
//    @ExcelProperty(value = "收货人手机号")
    @ApiModelProperty(value = "收货人手机号")
    @TableField("`mobile`")
    private String mobile;


    /**
     * 用户订单留言
     */
    @ExcelProperty(value = "订单备注",order = 16)
    @ApiModelProperty(value = "用户订单留言")
    @TableField("`message`")
    private String message;


    /**
     * 商品总费用
     */
//    @ExcelProperty(value = "商品总费用")
    @ApiModelProperty(value = "商品总费用")
    @TableField("`goods_price`")
    private BigDecimal goodsPrice;



    /**
     * 优惠券减免
     */
//    @ExcelProperty(value = "优惠券减免")
    @ApiModelProperty(value = "优惠券减免")
    @TableField("`coupon_price`")
    private BigDecimal couponPrice;



    /**
     * 订单费用， = goods_price + freight_price - coupon_price
     */
    @ApiModelProperty(value = "订单费用， = goods_price")
    @TableField("`order_price`")
    private BigDecimal orderPrice;


    //    @ExcelProperty(value = "实付费用， = order_price - coupon_price + freight_price ")
    @ExcelProperty(value = "实付金额",order = 14)
    @ApiModelProperty(value = "实付费用， = goods_price - coupon_price ")
    @TableField("`actual_price`")
    private BigDecimal actualPrice;

    /**
     * 支付方式 关联payType枚举  CR_PAY   消费券支付
     */
    @TableField("`pay_type`")
    @ApiModelProperty(value = "支付方式")
    private PayType payType;

    @ExcelProperty(value = "付款方式",order = 17)
    @ApiModelProperty(value = "支付方式")
    @TableField(exist = false)
    private String payTypeDesc;

    /**
     * 付款编号
     */
//    @ExcelProperty(value = "付款编号")
    @ApiModelProperty(value = "付款编号")
    @TableField("`pay_id`")
    private String payId;


    /**
     * 付款时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
//    @ExcelProperty(value = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",order = 12)
    @TableField("`pay_time`")
    private Date payTime;




    /**
     * 实际退款金额，（有可能退款金额小于实际支付金额）
     */
//    @ExcelProperty(value = "实际退款金额，", readConverterExp = "有=可能退款金额小于实际支付金额")
    @TableField("`refund_amount`")
    private BigDecimal refundAmount;


    /**
     * 退款方式
     */
//    @ExcelProperty(value = "退款方式")
    @ApiModelProperty(value = "退款方式")
    @TableField("`refund_type`")
    private String refundType;


    /**
     * 退款备注
     */
//    @ExcelProperty(value = "退款备注")
    @ApiModelProperty(value = "退款备注")
    @TableField("`refund_content`")
    private String refundContent;


    /**
     * 退款时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
//    @ExcelProperty(value = "退款时间", width = 30, dateFormat = "yyyy-MM-dd")
    @TableField("`refund_time`")
    private Date refundTime;


    /**
     * 描述信息  用户确认核销时间
     * @Author yaoruiqi
     * @Date: 2023/10/13 01:48
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("`confirm_time`")
    private Date confirmTime;



    /**
     * 待评价订单商品数量
     */
//    @ExcelProperty(value = "待评价订单商品数量")
    @ApiModelProperty(value = "待评价订单商品数量")
    @TableField("`comments`")
    private Integer comments;


    /**
     * 订单关闭时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
//    @ExcelProperty(value = "订单关闭时间", width = 30, dateFormat = "yyyy-MM-dd")
    @TableField("`end_time`")
    private LocalDateTime endTime;

    /**
     * 用户端是否删除（0否 1是）
     */
    @ApiModelProperty(value = "用户端是否删除（0否 1是）")
    @TableField("`app_del`")
    private Boolean appDel;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @TableLogic
    @TableField("`del_flag`")
    private String delFlag;

    @ApiModelProperty("创建时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty(value = "创建时间",order = 19)
    @ColumnWidth(18)
    @TableField(exist = false)
    private LocalDateTime createTime2;


    /**
     * 租户ID
     */
//    @ExcelProperty(value = "租户ID")
    @ApiModelProperty(value = "租户ID")
    @TableField("`tenant_id`")
    private Long tenantId;


    @ExcelProperty(value = "商品ID",order = 4)
    @ColumnWidth(9)
    private Long goodsId;


    //以下字段非数据库字段，作为返回字段处理
    //用户电话
    @TableField(exist = false)
    @ExcelProperty(value = "手机号码",order = 2)
    private String userPhone;
    //商品数量
    @ExcelProperty(value = "数量",order = 9)
    @TableField(exist = false)
    private Integer goodsNum;



    @TableField(exist = false)
    @ExcelProperty(value = "商品名称",order = 5)
    private String goodsName;

    @TableField(exist = false)
    private String picUrl;

    @TableField(exist = false)
    private String beginTime;

    @TableField(exist = false)
    private String endTimes;

    @TableField(exist = false)
    @ExcelProperty(value = "消费券价格",order = 10)
    private BigDecimal consumerPrice;

    @TableField(exist = false)
    private Long orderGoodsId;
    /****
     * 订单类型   1 店铺订单 2 商城订单订单发货
     *
     */
    @TableField(exist = false)
    private Long orderMold;
    /****
     * 是否取件
     */

    @TableField(exist = false)
    private Long take;

    @TableField(exist = false)
    private Long selfId;
    @TableField(exist = false)
    private Long normsId;

    @ApiModelProperty("上传商品的用户ID")
    @TableField(exist = false)
    private Long userId;

    @ApiModelProperty("店铺名称")
    @TableField(exist = false)
    private String storeName;



    @ApiModelProperty("商城商家名称")
    @ExcelProperty(order = 7,value = "供应商名称")
    @TableField(exist = false)
    private String username;

    @ApiModelProperty("规格名称")
    @ExcelProperty(order = 8, value = "商品规格")
    @TableField(exist = false)
    private String attribute;

    @TableField(exist = false)
    private  Integer orderTypeValue;

    @TableField(exist = false)
    private Integer type;

    @ApiModelProperty("订单异常状态")
    private OrderErrorStatusEnum orderErrorStatus;



    @TableField(exist = false)
    private Long category;

    @TableField(exist = false)
    private String oneLevel;

    @TableField(exist = false)
    private String twoLevel;

    @ApiModelProperty("货款")
    @TableField(exist = false)
    private BigDecimal payGoods;

}
